package listener;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;

import javax.swing.JButton;

import view.MainFrame;
import view.ResizeGlassPane;
import controller.LayerController;
import controller.ToolBarController;

public class ResizeGlassPaneListener implements MouseMotionListener, ActionListener
{

    @Override
    public void mouseDragged(MouseEvent e)
    {
        ResizeGlassPane resizeGlassPane = (ResizeGlassPane) MainFrame.getInstance().getGlassPane();
        resizeGlassPane.drawAResizeRect(e.getX(), e.getY());
    }

    @Override
    public void actionPerformed(ActionEvent arg0) {
        JButton butSrc = (JButton) arg0.getSource();
        if (butSrc.getName().equals("confirm")){
            ResizeGlassPane resizeGlassPane = (ResizeGlassPane)MainFrame.getInstance().getGlassPane();
            LayerController.resizeLayerTo(resizeGlassPane.getResizeDimension());
            ToolBarController.glassPaneOff();
        }
        if (butSrc.getName().equals("cancel")){
            ToolBarController.glassPaneOff();
        }
        
    }

    // ----- not used-----
    
    @Override
    public void mouseMoved(MouseEvent arg0)
    {
        
    }

}
